export const sortByArr = <T>(list: T[], key: keyof T, arr: string[]) => {
  let arr1: number[] = [];
  let arr2: T[] = [];
  list.forEach((item, index) => {
    const idx = arr.indexOf(item[key] as string);
    if (idx > -1) {
      arr1.push(index);
      arr2[idx] = item;
    }
  });
  arr2 = arr2.filter(item => item !== undefined);
  while (arr1.length) {
    const idx = arr1.shift()!;
    const item = arr2.shift()!;
    list[idx] = item;
  }
};
